<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>移动前端知识总结 | Jimmey-Jiang&#39;s Blog</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta name="description" content="移动时代本以为到移动端，就再也不用担心IE兼容问题，可是移动的设备，其实是更大的坑。面对这些问题，一开始我们只能在未知中试错，知道错误的方案，才能更容易寻找正确的解决问题思路。可看到移动web在业界不断趋向于成熟，各种框架和解决方案，不断的涌现让移动端开发不再是个噩梦。这几天把想到的一点经验先罗列出来，后续会持续更新，这篇文章可以给刚接触webapp开发的同学带来帮助，任何疑问欢迎留言探讨！">
<meta name="keywords" content="Mobile">
<meta property="og:type" content="article">
<meta property="og:title" content="移动前端知识总结">
<meta property="og:url" content="http://Jimmey-Jiang.github.io/2016/01/28/Induce/Mobile/Mobile-knowledge/index.html">
<meta property="og:site_name" content="Jimmey-Jiang&#39;s Blog">
<meta property="og:description" content="移动时代本以为到移动端，就再也不用担心IE兼容问题，可是移动的设备，其实是更大的坑。面对这些问题，一开始我们只能在未知中试错，知道错误的方案，才能更容易寻找正确的解决问题思路。可看到移动web在业界不断趋向于成熟，各种框架和解决方案，不断的涌现让移动端开发不再是个噩梦。这几天把想到的一点经验先罗列出来，后续会持续更新，这篇文章可以给刚接触webapp开发的同学带来帮助，任何疑问欢迎留言探讨！">
<meta property="og:locale" content="zh-Hans">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1064727-354d2f3142523da6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:image" content="http://upload-images.jianshu.io/upload_images/1064727-8f498bb8f55c4844.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
<meta property="og:updated_time" content="2017-07-28T10:54:48.000Z">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="移动前端知识总结">
<meta name="twitter:description" content="移动时代本以为到移动端，就再也不用担心IE兼容问题，可是移动的设备，其实是更大的坑。面对这些问题，一开始我们只能在未知中试错，知道错误的方案，才能更容易寻找正确的解决问题思路。可看到移动web在业界不断趋向于成熟，各种框架和解决方案，不断的涌现让移动端开发不再是个噩梦。这几天把想到的一点经验先罗列出来，后续会持续更新，这篇文章可以给刚接触webapp开发的同学带来帮助，任何疑问欢迎留言探讨！">
<meta name="twitter:image" content="http://upload-images.jianshu.io/upload_images/1064727-354d2f3142523da6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240">
  
    <link rel="alternative" href="/atom.xml" title="Jimmey-Jiang&#39;s Blog" type="application/atom+xml">
  
  
    <link rel="icon" href="/img/favicon.png">
  
  
      <link rel="stylesheet" href="//cdn.bootcss.com/animate.css/3.5.0/animate.min.css">
  
  <link rel="stylesheet" href="/css/style.css">
  <link rel="stylesheet" href="/font-awesome/css/font-awesome.min.css">
  <link rel="apple-touch-icon" href="/apple-touch-icon.png">
  
  
      <link rel="stylesheet" href="/fancybox/jquery.fancybox.css">
  
  <!-- 加载特效 -->
    <script src="/js/pace.js"></script>
    <link href="/css/pace/pace-theme-flash.css" rel="stylesheet" />
  <script>
      var yiliaConfig = {
          rootUrl: '/',
          fancybox: true,
          animate: true,
          isHome: false,
          isPost: true,
          isArchive: false,
          isTag: false,
          isCategory: false,
          open_in_new: false
      }
  </script>
</head>
<body>
  <div id="container">
    <div class="left-col">
    <div class="overlay"></div>
<div class="intrude-less">
    <header id="header" class="inner">
        <a href="/" class="profilepic">
            
            <img lazy-src="/img/head.jpg" class="js-avatar">
            
        </a>

        <hgroup>
          <h1 class="header-author"><a href="/" title="Hi Mate">安与生</a></h1>
        </hgroup>

        
        <p class="header-subtitle">城已成，兵不封，鼓不停，志不移，行不息</p>
        
        
            <form>
                <input type="text" class="st-default-search-input search" id="search" placeholder=" Search...">
            </form>
        
        
            <div id="switch-btn" class="switch-btn">
                <div class="icon">
                    <div class="icon-ctn">
                        <div class="icon-wrap icon-house" data-idx="0">
                            <div class="birdhouse"></div>
                            <div class="birdhouse_holes"></div>
                        </div>
                        <div class="icon-wrap icon-ribbon hide" data-idx="1">
                            <div class="ribbon"></div>
                        </div>
                        
                        <div class="icon-wrap icon-link hide" data-idx="2">
                            <div class="loopback_l"></div>
                            <div class="loopback_r"></div>
                        </div>
                        
                        
                        <div class="icon-wrap icon-me hide" data-idx="3">
                            <div class="user"></div>
                            <div class="shoulder"></div>
                        </div>
                        
                    </div>
                    
                </div>
                <div class="tips-box hide">
                    <div class="tips-arrow"></div>
                    <ul class="tips-inner">
                        <li>菜单</li>
                        <li>标签</li>
                        
                        <li>友情链接</li>
                        
                        
                        <li>关于我</li>
                        
                    </ul>
                </div>
            </div>
        

        <div id="switch-area" class="switch-area">
            <div class="switch-wrap">
                <section class="switch-part switch-part1">
                    <nav class="header-menu">
                        <ul>
                        
                            <li><a href="/archives">所有文章</a></li>
                        
                            <li><a href="/works">作品展示</a></li>
                        
                           <li><a href="/about">留言打卡</a></li>
                        
                            <li><a  target="_blank" href="https://tuchong.com/1496450/">摄影集展示</a></li>
                        
                        </ul>
                    </nav>
                    <nav class="header-nav">
                        <ul class="social">
                            
                                <a class="fl mail" target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=4trX0tXT19PV1aKTk8yBjY8" title="mail">mail</a>
                            
                                <a class="fl github" target="_blank" href="https://github.com/Jimmey-Jiang" title="github">github</a>
                            
                                <a class="fl zhihu" target="_blank" href="https://www.zhihu.com" title="zhihu">zhihu</a>
                            
                                <a class="fl weibo" target="_blank" href="http://weibo.com" title="weibo">weibo</a>
                            
                                <a class="fl google" target="_blank" href="http://i.youku.com" title="google">google</a>
                            
                                <a class="fl twitter" target="_blank" href="http://twitter.com" title="twitter">twitter</a>
                            
                                <a class="fl Instagram" target="_blank" href="https://www.instagram.com" title="Instagram">Instagram</a>
                            
                                <a class="fl linkedin" target="_blank" href="https://www.linkedin.com" title="linkedin">linkedin</a>
                            
                        </ul>
                    </nav>
                </section>
                
                
                <section class="switch-part switch-part2">
                    <div class="widget tagcloud" id="js-tagcloud">
                        <a href="/tags/Ajax/" style="font-size: 11.67px;">Ajax</a> <a href="/tags/CDN/" style="font-size: 10px;">CDN</a> <a href="/tags/CSS/" style="font-size: 18.33px;">CSS</a> <a href="/tags/CSS3/" style="font-size: 11.67px;">CSS3</a> <a href="/tags/Chrome/" style="font-size: 10px;">Chrome</a> <a href="/tags/Development/" style="font-size: 10px;">Development</a> <a href="/tags/Front-end-outline/" style="font-size: 10px;">Front end outline</a> <a href="/tags/FrontPlan/" style="font-size: 10px;">FrontPlan</a> <a href="/tags/Git/" style="font-size: 11.67px;">Git</a> <a href="/tags/Gulp/" style="font-size: 10px;">Gulp</a> <a href="/tags/HTML/" style="font-size: 13.33px;">HTML</a> <a href="/tags/Hack/" style="font-size: 10px;">Hack</a> <a href="/tags/Hexo/" style="font-size: 16.67px;">Hexo</a> <a href="/tags/Interview/" style="font-size: 10px;">Interview</a> <a href="/tags/JavaScript/" style="font-size: 13.33px;">JavaScript</a> <a href="/tags/Javascript/" style="font-size: 10px;">Javascript</a> <a href="/tags/Markdown/" style="font-size: 10px;">Markdown</a> <a href="/tags/Mobile/" style="font-size: 13.33px;">Mobile</a> <a href="/tags/NodeJs/" style="font-size: 10px;">NodeJs</a> <a href="/tags/OOCSS/" style="font-size: 10px;">OOCSS</a> <a href="/tags/React/" style="font-size: 10px;">React</a> <a href="/tags/ReactNative/" style="font-size: 20px;">ReactNative</a> <a href="/tags/Sass/" style="font-size: 10px;">Sass</a> <a href="/tags/Sublime/" style="font-size: 15px;">Sublime</a> <a href="/tags/Terminal/" style="font-size: 10px;">Terminal</a> <a href="/tags/Video/" style="font-size: 10px;">Video</a> <a href="/tags/Vue/" style="font-size: 15px;">Vue</a> <a href="/tags/WeChatSDK/" style="font-size: 10px;">WeChatSDK</a> <a href="/tags/rem/" style="font-size: 10px;">rem</a> <a href="/tags/window-7/" style="font-size: 10px;">window 7</a>
                    </div>
                </section>
                
                
                
                <section class="switch-part switch-part3">
                    <div id="js-friends">
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://MOxFIVE.github.io/">MOxFIVE</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.vsay.cn/">DoubleV</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.ccwebsite.com/">兮兮</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.dandyweng.com/">翁天信</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.plqblog.com/views/index.php">潘利强</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://www.hankin.cn/">hankin</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="http://blog.waydrow.com/">waydrow</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://www.tangbc.com">TANGBC</a>
                    
                      <a target="_blank" class="main-nav-link switch-friends-link" href="https://www.w3ctrain.com/">Helkyle</a>
                    
                    </div>
                </section>
                

                
                
                <section class="switch-part switch-part4">
                
                    <div id="js-aboutme">城已成，兵不封，鼓不停，志不移，行不息</div>
                </section>
                
            </div>
        </div>
    </header>                
</div>
    </div>
    <div class="mid-col">
      <nav id="mobile-nav">
      <div class="overlay">
          <div class="slider-trigger"></div>
          <h1 class="header-author js-mobile-header hide"><a href="/" title="Me">安与生</a></h1>
      </div>
    <div class="intrude-less">
        <header id="header" class="inner">
            <a href="/" class="profilepic">
                
                    <img lazy-src="/img/head.jpg" class="js-avatar">
                
            </a>
            <hgroup>
              <h1 class="header-author"><a href="/" title="Me">安与生</a></h1>
            </hgroup>
            
            <p class="header-subtitle">城已成，兵不封，鼓不停，志不移，行不息</p>
            
            <nav class="header-menu">
                <ul>
                
                    <li><a href="/archives">所有文章</a></li>
                
                    <li><a href="/works">作品展示</a></li>
                
                   <li><a href="/about">留言打卡</a></li>
                
                    <li><a  target="_blank" href="https://tuchong.com/1496450/">摄影集展示</a></li>
                
                <div class="clearfix"></div>
                </ul>
            </nav>
            <nav class="header-nav">
                <div class="social">
                    
                        <a class="mail" target="_blank" href="http://mail.qq.com/cgi-bin/qm_share?t=qm_mailme&email=4trX0tXT19PV1aKTk8yBjY8" title="mail">mail</a>
                    
                        <a class="github" target="_blank" href="https://github.com/Jimmey-Jiang" title="github">github</a>
                    
                        <a class="zhihu" target="_blank" href="https://www.zhihu.com" title="zhihu">zhihu</a>
                    
                        <a class="weibo" target="_blank" href="http://weibo.com" title="weibo">weibo</a>
                    
                        <a class="google" target="_blank" href="http://i.youku.com" title="google">google</a>
                    
                        <a class="twitter" target="_blank" href="http://twitter.com" title="twitter">twitter</a>
                    
                        <a class="Instagram" target="_blank" href="https://www.instagram.com" title="Instagram">Instagram</a>
                    
                        <a class="linkedin" target="_blank" href="https://www.linkedin.com" title="linkedin">linkedin</a>
                    
                </div>
            </nav>
        </header>                
    </div>
</nav>
      <div class="body-wrap"><article id="post-Induce/Mobile/Mobile-knowledge" class="article article-type-post" itemscope itemprop="blogPost">
  
    <div class="article-meta">
      <a href="/2016/01/28/Induce/Mobile/Mobile-knowledge/" class="article-date">
      <time datetime="2016-01-28T06:11:20.000Z" itemprop="datePublished">2016-01-28</time>
</a>
    </div>
  
  <div class="article-inner">
    
      <input type="hidden" class="isFancy" />
    
    
      <header class="article-header">
        
  
    <h1 class="article-title" itemprop="name">
      移动前端知识总结
    </h1>
  

      </header>
      
      <div class="article-info article-info-post">
        
    <div class="article-category tagcloud">
    <a class="article-category-link" href="/categories/Induce/">Induce</a>
    </div>

        
    <div class="article-tag tagcloud">
        <ul class="article-tag-list"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Mobile/">Mobile</a></li></ul>
    </div>

        <div class="clearfix"></div>
      </div>
      
    
    <div class="article-entry" itemprop="articleBody">
      
          
        <p>　　移动时代本以为到移动端，就再也不用担心IE兼容问题，可是移动的设备，其实是更大的坑。面对这些问题，一开始我们只能在未知中试错，知道错误的方案，才能更容易寻找正确的解决问题思路。可看到移动web在业界不断趋向于成熟，各种框架和解决方案，不断的涌现让移动端开发不再是个噩梦。<br>这几天把想到的一点经验先罗列出来，后续会持续更新，这篇文章可以给刚接触webapp开发的同学带来帮助，任何疑问欢迎留言探讨！<br><a id="more"></a></p>
<table>
<thead>
<tr>
<th>前因</th>
<th>后果</th>
</tr>
</thead>
<tbody>
<tr>
<td>设备更新换代快</td>
<td>低端机遗留下问题、高端机带来新挑战</td>
</tr>
<tr>
<td>浏览器厂商不统一</td>
<td>兼容问题多</td>
</tr>
<tr>
<td>网络更复杂</td>
<td>弱网络，页面打开慢</td>
</tr>
<tr>
<td>低端机性能差</td>
<td>页面操作卡顿</td>
</tr>
<tr>
<td>HTML5新技术多</td>
<td>学习成本不低</td>
</tr>
<tr>
<td>未知问题</td>
<td>坑多</td>
</tr>
</tbody>
</table>
<h3 id="常见问题"><a href="#常见问题" class="headerlink" title="常见问题"></a>常见问题</h3><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">移动端如何定义字体<span class="selector-tag">font-family</span></div><div class="line">中文字体使用系统默认即可，英文用<span class="selector-tag">Helvetica</span></div><div class="line"><span class="comment">/* 移动端定义字体的代码 */</span><span class="selector-tag">body</span>&#123;<span class="attribute">font-family</span>:Helvetica;&#125;</div></pre></td></tr></table></figure>
<p>参考《<a href="http://www.cnblogs.com/PeunZhang/p/3592096.html" target="_blank" rel="external">移动端使用字体的思考</a>》<br>移动端字体单位font-size选择px还是rem</p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">对于只需要适配少部分手机设备，且分辨率对页面影响不大的，使用px即可</div><div class="line">对于需要适配各种移动设备，使用<span class="keyword">rem</span>，例如只需要适配iPhone和iPad等分辨率差别比较挺大的设备</div></pre></td></tr></table></figure>
<h3 id="meta基础知识"><a href="#meta基础知识" class="headerlink" title="meta基础知识"></a>meta基础知识</h3><h4 id="H5页面窗口自动调整到设备宽度，并禁止用户缩放页面"><a href="#H5页面窗口自动调整到设备宽度，并禁止用户缩放页面" class="headerlink" title="H5页面窗口自动调整到设备宽度，并禁止用户缩放页面"></a>H5页面窗口自动调整到设备宽度，并禁止用户缩放页面</h4><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;meta <span class="attribute">name</span>=<span class="string">"viewport"</span> <span class="attribute">content</span>=<span class="string">"width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"</span> /&gt;</div></pre></td></tr></table></figure>
<h4 id="忽略将页面中的数字识别为电话号码"><a href="#忽略将页面中的数字识别为电话号码" class="headerlink" title="忽略将页面中的数字识别为电话号码"></a>忽略将页面中的数字识别为电话号码</h4><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;meta <span class="attribute">name</span>=<span class="string">"format-detection"</span> <span class="attribute">content</span>=<span class="string">"telephone=no"</span> /&gt;</div></pre></td></tr></table></figure>
<h4 id="忽略Android平台中对邮箱地址的识别"><a href="#忽略Android平台中对邮箱地址的识别" class="headerlink" title="忽略Android平台中对邮箱地址的识别"></a>忽略Android平台中对邮箱地址的识别</h4><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;meta <span class="attribute">name</span>=<span class="string">"format-detection"</span> <span class="attribute">content</span>=<span class="string">"email=no"</span> /&gt;</div></pre></td></tr></table></figure>
<h4 id="当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari"><a href="#当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari" class="headerlink" title="当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari"></a>当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span> <span class="attr">content</span>=<span class="string">"yes"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- ios7.0版本以后，safari上已看不到效果 --&gt;</span></div></pre></td></tr></table></figure>
<p>体验demo，解决在主屏幕打开页面后，点击页面链接不会跳转到系统自带的Safari<br><img src="http://upload-images.jianshu.io/upload_images/1064727-354d2f3142523da6.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
<h4 id="将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式"><a href="#将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式" class="headerlink" title="将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式"></a>将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span> <span class="attr">content</span>=<span class="string">"black"</span> /&gt;</span></div><div class="line"><span class="comment">&lt;!-- 可选default、black、black-translucent --&gt;</span></div></pre></td></tr></table></figure>
<h3 id="viewport模板"><a href="#viewport模板" class="headerlink" title="viewport模板"></a>viewport模板</h3><h4 id="viewport模板——通用"><a href="#viewport模板——通用" class="headerlink" title="viewport模板——通用"></a>viewport模板——通用</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span> <span class="attr">name</span>=<span class="string">"viewport"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"yes"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"black"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"telephone=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"email=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">title</span>&gt;</span>标题<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">"stylesheet"</span> <span class="attr">href</span>=<span class="string">"index.css"</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span>这里开始内容<span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<h4 id="viewport模板-target-densitydpi-device-dpi，android-2-3-5以下版本不支持"><a href="#viewport模板-target-densitydpi-device-dpi，android-2-3-5以下版本不支持" class="headerlink" title="viewport模板 - target-densitydpi=device-dpi，android 2.3.5以下版本不支持"></a>viewport模板 - target-densitydpi=device-dpi，android 2.3.5以下版本不支持</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">name</span>=<span class="string">"viewport"</span> <span class="attr">content</span>=<span class="string">"width=750, user-scalable=no, target-densitydpi=device-dpi"</span>&gt;</span></div><div class="line"><span class="comment">&lt;!-- width取值与页面定义的宽度一致 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"yes"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"black"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"telephone=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"email=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">title</span>&gt;</span>标题<span class="tag">&lt;/<span class="name">title</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">link</span> <span class="attr">rel</span>=<span class="string">"stylesheet"</span> <span class="attr">href</span>=<span class="string">"index.css"</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span>这里开始内容<span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<p>参考案例：<a href="http://action.weixin.qq.com/payact/readtemplate?t=mobile/2015/wxzfsht/index_tmpl" target="_blank" rel="external">http://action.weixin.qq.com/payact/readtemplate?t=mobile/2015/wxzfsht/index_tmpl</a></p>
<h3 id="rem配置参考："><a href="#rem配置参考：" class="headerlink" title="rem配置参考："></a>rem配置参考：</h3><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">html&#123;</div><div class="line">font-size:10px&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:321px) <span class="keyword">and</span> (max-width:375px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:11px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:376px) <span class="keyword">and</span> (max-width:414px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:12px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:415px) <span class="keyword">and</span> (max-width:639px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:15px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:640px) <span class="keyword">and</span> (max-width:719px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:20px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:720px) <span class="keyword">and</span> (max-width:749px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:22.5px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:750px) <span class="keyword">and</span> (max-width:799px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:23.5px&#125;&#125;@media<span class="built_in"> screen </span><span class="keyword">and</span> (min-width:800px)&#123;</div><div class="line">html&#123;</div><div class="line">font-size:25px&#125;&#125;</div></pre></td></tr></table></figure>
<p>体验demo：<a href="http://1.peunzhang.sinaapp.com/demo/rem/index.html" target="_blank" rel="external">http://1.peunzhang.sinaapp.com/demo/rem/index.html</a></p>
<figure class="highlight less"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">移动端<span class="selector-tag">touch</span>事件(区分webkit 和 winphone)</div><div class="line">当用户手指放在移动设备在屏幕上滑动会触发的<span class="selector-tag">touch</span>事件</div><div class="line">以下支持<span class="selector-tag">webkit</span></div><div class="line"><span class="selector-tag">touchstart</span>——当手指触碰屏幕时候发生。不管当前有多少只手指</div><div class="line"><span class="selector-tag">touchmove</span>——当手指在屏幕上滑动时连续触发。通常我们再滑屏页面，会调用<span class="selector-tag">event</span>的<span class="selector-tag">preventDefault</span>()可以阻止默认情况的发生：阻止页面滚动</div><div class="line"><span class="selector-tag">touchend</span>——当手指离开屏幕时触发</div><div class="line"><span class="selector-tag">touchcancel</span>——系统停止跟踪触摸时候会触发。例如在触摸过程中突然页面<span class="selector-tag">alert</span>()一个提示框，此时会触发该事件，这个事件比较少用</div></pre></td></tr></table></figure>
<figure class="highlight nginx"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line"><span class="attribute">TouchEvent</span></div><div class="line">touches：屏幕上所有手指的信息</div><div class="line">targetTouches：手指在目标区域的手指信息</div><div class="line">changedTouches：最近一次触发该事件的手指信息</div><div class="line">touchend时，touches与targetTouches信息会被删除，changedTouches保存的最后一次的信息，最好用于计算手指信息</div></pre></td></tr></table></figure>
<p>参数信息(changedTouches[0])<br>clientX、clientY在显示区的坐标<br>target：当前元素</p>
<p>参考：<a href="https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent" target="_blank" rel="external">https://developer.mozilla.org/en-US/docs/Web/API/TouchEvent</a><br>以下支持winphone 8<br>MSPointerDown——当手指触碰屏幕时候发生。不管当前有多少只手指<br>MSPointerMove——当手指在屏幕上滑动时连续触发。通常我们再滑屏页面，会调用css的html{<br>-ms-touch-action: none;}可以阻止默认情况的发生：阻止页面滚动<br>MSPointerUp——当手指离开屏幕时触发</p>
<p>移动端click屏幕产生200-300 ms的延迟响应<br>移动设备上的web网页是有300ms延迟的，玩玩会造成按钮点击延迟甚至是点击失效。<br>以下是历史原因，来源一个公司内一个同事的分享：<br>2007年苹果发布首款iphone上IOS系统搭载的safari为了将适用于PC端上大屏幕的网页能比较好的展示在手机端上，使用了双击缩放(double tap to zoom)的方案，比如你在手机上用浏览器打开一个PC上的网页，你可能在看到页面内容虽然可以撑满整个屏幕，但是字体、图片都很小看不清，此时可以快速双击屏幕上的某一部分，你就能看清该部分放大后的内容，再次双击后能回到原始状态。<br>双击缩放是指用手指在屏幕上快速点击两次，iOS 自带的 Safari 浏览器会将网页缩放至原始比例。</p>
<figure class="highlight excel"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">原因就出在浏览器需要如何判断快速点击上，当用户在屏幕上单击某一个元素时候，例如跳转链接&lt;a href=<span class="string">"#"</span>&gt;</div><div class="line">&lt;/a&gt;，此处浏览器会先捕获该次单击，但浏览器不能决定用户是单纯要点击链接还是要双击该部分区域进行缩放操作，所以，捕获第一次单击后，浏览器会先Hold一段时间<span class="built_in">t</span>，如果在<span class="built_in">t</span>时间区间里用户未进行下一次点击，则浏览器会做单击跳转链接的处理，如果<span class="built_in">t</span>时间里用户进行了第二次单击操作，则浏览器会禁止跳转，转而进行对该部分区域页面的缩放操作。那么这个时间区间<span class="built_in">t</span>有多少呢？在IOS safari下，大概为<span class="number">300</span>毫秒。这就是延迟的由来。造成的后果用户纯粹单击页面，页面需要过一段时间才响应，给用户慢体验感觉，对于web开发者来说是，页面js捕获click事件的回调函数处理，需要<span class="number">300</span>ms后才生效，也就间接导致影响其他业务逻辑的处理。</div></pre></td></tr></table></figure>
<p>解决方案：<br>fastclick可以解决在手机上点击事件的300ms延迟<br>zepto的touch模块，tap事件也是为了解决在click的延迟问题</p>
<p>触摸事件的响应顺序<br>1、ontouchstart 2、ontouchmove 3、ontouchend 4、onclick</p>
<p>解决300ms延迟的问题，也可以通过绑定ontouchstart事件，加快对事件的响应<br>什么是Retina 显示屏，带来了什么问题<br>retina：一种具备超高像素密度的液晶屏，同样大小的屏幕上显示的像素点由1个变为多个，如在同样带下的屏幕上，苹果设备的retina显示屏中，像素点1个变为4个<br>在高清显示屏中的位图被放大，图片会变得模糊，因此移动端的视觉稿通常会设计为传统PC的2倍<br>那么，前端的应对方案是：<br>设计稿切出来的图片长宽保证为偶数，并使用backgroud-size把图片缩小为原来的1/2<br>//例如图片宽高为：200px*200px，那么写法如下.css{width:100px;height:100px;background-size:100px 100px;}</p>
<p>其它元素的取值为原来的1/2，例如视觉稿40px的字体，使用样式的写法为20px<br>.css{font-size:20px}</p>
<p>参考《<a href="http://www.cnblogs.com/PeunZhang/p/3441110.html" target="_blank" rel="external">高清显示屏原理及设计方案</a>》<br>ios系统中元素被触摸时产生的半透明灰色遮罩怎么去掉<br>ios用户点击一个链接，会出现一个半透明灰色遮罩, 如果想要禁用，可设置-webkit-tap-highlight-color的alpha值为0，也就是属性值的最后一位设置为0就可以去除半透明灰色遮罩<br>a,button,input,textarea{-webkit-tap-highlight-color: rgba(0,0,0,0;)}</p>
<p>部分android系统中元素被点击时产生的边框怎么去掉<br>android用户点击一个链接，会出现一个边框或者半透明灰色遮罩, 不同生产商定义出来额效果不一样，可设置-webkit-tap-highlight-color的alpha值为0去除部分机器自带的效果<br>a,button,input,textarea{-webkit-tap-highlight-color: rgba(0,0,0,0;)-webkit-user-modify:read-write-plaintext-only; }</p>
<p>-webkit-user-modify有个副作用，就是输入法不再能够输入多个字符<br>另外，有些机型去除不了，如小米2<br>对于按钮类还有个办法，不使用a或者input标签，直接用div标签<br>参考《<a href="http://www.cnblogs.com/PeunZhang/archive/2013/02/28/2907708.html" target="_blank" rel="external">如何去除android上a标签产生的边框</a>》</p>
<h4 id="winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉"><a href="#winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉" class="headerlink" title="winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉"></a>winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉</h4><figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;meta <span class="attribute">name</span>=<span class="string">"msapplication-tap-highlight"</span> <span class="attribute">content</span>=<span class="string">"no"</span>&gt;</div></pre></td></tr></table></figure>
<h4 id="webkit表单元素的默认外观怎么重置"><a href="#webkit表单元素的默认外观怎么重置" class="headerlink" title="webkit表单元素的默认外观怎么重置"></a>webkit表单元素的默认外观怎么重置</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.css</span>&#123;<span class="attribute">-webkit-appearance</span>:none;&#125;</div></pre></td></tr></table></figure>
<h4 id="webkit表单输入框placeholder的颜色值能改变么"><a href="#webkit表单输入框placeholder的颜色值能改变么" class="headerlink" title="webkit表单输入框placeholder的颜色值能改变么"></a>webkit表单输入框placeholder的颜色值能改变么</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">input</span><span class="selector-pseudo">::-webkit-input-placeholder</span>&#123;<span class="attribute">color</span>:<span class="number">#AAAAAA</span>;&#125;<span class="selector-tag">input</span><span class="selector-pseudo">:focus</span><span class="selector-pseudo">::-webkit-input-placeholder</span>&#123;<span class="attribute">color</span>:<span class="number">#EEEEEE</span>;&#125;</div></pre></td></tr></table></figure>
<h4 id="webkit表单输入框placeholder的文字能换行么"><a href="#webkit表单输入框placeholder的文字能换行么" class="headerlink" title="webkit表单输入框placeholder的文字能换行么"></a>webkit表单输入框placeholder的文字能换行么</h4><figure class="highlight asciidoc"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">ios可以，android不行~</div><div class="line">在textarea标签下都可以换行~</div><div class="line">IE10（winphone8）表单元素默认外观如何重置</div><div class="line">禁用 select 默认下拉箭头</div><div class="line"><span class="meta">::-ms-expand 适用于表单选择控件下拉箭头的修改，有多个属性值，设置它隐藏 (display:none)</span> 并使用背景图片来修饰可得到我们想要的效果。</div><div class="line">select::-ms-expand &#123;display: none;&#125;</div></pre></td></tr></table></figure>
<h4 id="禁用-radio-和-checkbox-默认样式"><a href="#禁用-radio-和-checkbox-默认样式" class="headerlink" title="禁用 radio 和 checkbox 默认样式"></a>禁用 radio 和 checkbox 默认样式</h4><figure class="highlight elixir"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line"><span class="symbol">:</span><span class="symbol">:-ms-check</span> 适用于表单复选框或单选按钮默认图标的修改，同样有多个属性值，设置它隐藏 (<span class="symbol">display:</span>none) 并使用背景图片来修饰可得到我们想要的效果。</div><div class="line">input[type=radio]<span class="symbol">:</span><span class="symbol">:-ms-check</span>,input[type=checkbox]<span class="symbol">:</span><span class="symbol">:-ms-check</span>&#123;<span class="symbol">display:</span> none;&#125;</div></pre></td></tr></table></figure>
<h4 id="禁用PC端表单输入框默认清除按钮"><a href="#禁用PC端表单输入框默认清除按钮" class="headerlink" title="禁用PC端表单输入框默认清除按钮"></a>禁用PC端表单输入框默认清除按钮</h4><figure class="highlight elixir"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">当表单文本输入框输入内容后会显示文本清除按钮，</div><div class="line"><span class="symbol">:</span><span class="symbol">:-ms-clear</span> 适用于该清除按钮的修改，同样设置使它隐藏 (<span class="symbol">display:</span>none) 并使用背景图片来修饰可得到我们想要的效果。</div><div class="line">input[type=text]<span class="symbol">:</span><span class="symbol">:-ms-clear</span>,input[type=tel]<span class="symbol">:</span><span class="symbol">:-ms-clear</span>,input[type=number]<span class="symbol">:</span><span class="symbol">:-ms-clear</span>&#123;<span class="symbol">display:</span> none;&#125;</div></pre></td></tr></table></figure>
<h4 id="禁止ios-长按时不触发系统的菜单，禁止ios-amp-android长按时下载图片"><a href="#禁止ios-长按时不触发系统的菜单，禁止ios-amp-android长按时下载图片" class="headerlink" title="禁止ios 长按时不触发系统的菜单，禁止ios&amp;android长按时下载图片"></a>禁止ios 长按时不触发系统的菜单，禁止ios&amp;android长按时下载图片</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.css</span>&#123;<span class="attribute">-webkit-touch-callout</span>: none&#125;</div></pre></td></tr></table></figure>
<h4 id="禁止ios和android用户选中文字"><a href="#禁止ios和android用户选中文字" class="headerlink" title="禁止ios和android用户选中文字"></a>禁止ios和android用户选中文字</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.css</span>&#123;<span class="attribute">-webkit-user-select</span>:none&#125;</div></pre></td></tr></table></figure>
<p>参考《<a href="http://www.cnblogs.com/PeunZhang/p/3522603.html" target="_blank" rel="external">如何改变表单元素的外观(for Webkit and IE10)</a>》</p>
<h4 id="打电话发短信写邮件怎么实现"><a href="#打电话发短信写邮件怎么实现" class="headerlink" title="打电话发短信写邮件怎么实现"></a>打电话发短信写邮件怎么实现</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">打电话</div><div class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"tel:0755-10086"</span>&gt;</span>打电话给:0755-10086<span class="tag">&lt;/<span class="name">a</span>&gt;</span></div></pre></td></tr></table></figure>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div></pre></td><td class="code"><pre><div class="line">发短信，winphone系统无效</div><div class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"sms:10086"</span>&gt;</span>发短信给: 10086<span class="tag">&lt;/<span class="name">a</span>&gt;</span></div></pre></td></tr></table></figure>
<p>写邮件，可参考《<a href="http://www.cnblogs.com/PeunZhang/p/4952783.html" target="_blank" rel="external">移动web页面给用户发送邮件的方法</a>》</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="tag">&lt;<span class="name">a</span> <span class="attr">href</span>=<span class="string">"mailto:peun@foxmail.com"</span>&gt;</span>peun@foxmail.com<span class="tag">&lt;/<span class="name">a</span>&gt;</span></div></pre></td></tr></table></figure>
<h4 id="模拟按钮hover效果"><a href="#模拟按钮hover效果" class="headerlink" title="模拟按钮hover效果"></a>模拟按钮hover效果</h4><p>移动端触摸按钮的效果，可明示用户有些事情正要发生，是一个比较好体验，但是移动设备中并没有鼠标指针，使用css的hover并不能满足我们的需求，还好国外有个激活css的active效果，代码如下，</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span> <span class="attr">name</span>=<span class="string">"viewport"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"yes"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"black"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"telephone=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"email=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span><span class="css"></span></div><div class="line">	<span class="selector-tag">a</span>&#123;</div><div class="line">		<span class="attribute">-webkit-tap-highlight-color</span>: <span class="built_in">rgba</span>(0,0,0,0);</div><div class="line">	&#125;</div><div class="line">	<span class="selector-class">.btn-blue</span>&#123;</div><div class="line">		<span class="attribute">display</span>:block;</div><div class="line">		<span class="attribute">height</span>:<span class="number">42px</span>;</div><div class="line">		<span class="attribute">line-height</span>:<span class="number">42px</span>;</div><div class="line">		<span class="attribute">text-align</span>:center;</div><div class="line">		<span class="attribute">border-radius</span>:<span class="number">4px</span>;</div><div class="line">		<span class="attribute">font-size</span>:<span class="number">18px</span>;</div><div class="line">		<span class="attribute">color</span>:<span class="number">#FFFFFF</span>;</div><div class="line">		<span class="attribute">background-color</span>: <span class="number">#4185F3</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="selector-class">.btn-blue</span><span class="selector-pseudo">:active</span>&#123;</div><div class="line">		<span class="attribute">background-color</span>: <span class="number">#357AE8</span>;</div><div class="line">	&#125;</div><div class="line">	<span class="tag">&lt;/<span class="name">style</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"btn-blue"</span>&gt;</span>按钮<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line">	<span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">"text/javascript"</span>&gt;</span><span class="javascript"></span></div><div class="line">		<span class="built_in">document</span>.addEventListener(<span class="string">"touchstart"</span>, <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</div><div class="line">		&#125;, <span class="literal">true</span>)</div><div class="line">	<span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<p>兼容性ios5+、部分android 4+、winphone 8<br>要做到全兼容的办法，可通过绑定ontouchstart和ontouchend来控制按钮的类名</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span> <span class="attr">name</span>=<span class="string">"viewport"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"yes"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"black"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"telephone=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"email=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span><span class="css"><span class="selector-tag">a</span>&#123;<span class="attribute">-webkit-tap-highlight-color</span>: <span class="built_in">rgba</span>(0,0,0,0);&#125;<span class="selector-class">.btn-blue</span>&#123;<span class="attribute">display</span>:block;<span class="attribute">height</span>:<span class="number">42px</span>;<span class="attribute">line-height</span>:<span class="number">42px</span>;<span class="attribute">text-align</span>:center;<span class="attribute">border-radius</span>:<span class="number">4px</span>;<span class="attribute">font-size</span>:<span class="number">18px</span>;<span class="attribute">color</span>:<span class="number">#FFFFFF</span>;<span class="attribute">background-color</span>: <span class="number">#4185F3</span>;&#125;<span class="selector-class">.btn-blue-on</span>&#123;<span class="attribute">background-color</span>: <span class="number">#357AE8</span>;&#125;</span><span class="tag">&lt;/<span class="name">style</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"btn-blue"</span>&gt;</span>按钮<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">script</span> <span class="attr">type</span>=<span class="string">"text/javascript"</span>&gt;</span><span class="javascript"><span class="keyword">var</span> btnBlue = <span class="built_in">document</span>.querySelector(<span class="string">".btn-blue"</span>);btnBlue.ontouchstart = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123; <span class="keyword">this</span>.className = <span class="string">"btn-blue btn-blue-on"</span>&#125;btnBlue.ontouchend = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123; <span class="keyword">this</span>.className = <span class="string">"btn-blue"</span>&#125;</span><span class="tag">&lt;/<span class="name">script</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<p>屏幕旋转的事件和样式</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">事件</div><div class="line"><span class="built_in">window</span>.orientation，取值：正负<span class="number">90</span>表示横屏模式、<span class="number">0</span>和<span class="number">180</span>表现为竖屏模式；</div><div class="line"></div><div class="line"><span class="built_in">window</span>.onorientationchange = <span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123;</div><div class="line">	<span class="keyword">switch</span>(<span class="built_in">window</span>.orientation)&#123;</div><div class="line">		<span class="keyword">case</span> <span class="number">-90</span>: <span class="keyword">case</span> <span class="number">90</span>: alert(<span class="string">"横屏:"</span> + <span class="built_in">window</span>.orientation);</div><div class="line">		<span class="keyword">case</span> <span class="number">0</span>: <span class="keyword">case</span> <span class="number">180</span>: alert(<span class="string">"竖屏:"</span> + <span class="built_in">window</span>.orientation);</div><div class="line">		<span class="keyword">break</span>;</div><div class="line">	&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<figure class="highlight aspectj"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">样式</div><div class="line"></div><div class="line"><span class="comment">//竖屏时使用的样式</span></div><div class="line"></div><div class="line"><span class="meta">@media</span> <span class="function">all <span class="title">and</span> <span class="params">(orientation:portrait)</span> </span>&#123;</div><div class="line">	.css&#123;&#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"><span class="comment">//横屏时使用的样式</span></div><div class="line"><span class="meta">@media</span> <span class="function">all <span class="title">and</span> <span class="params">(orientation:landscape)</span> </span>&#123;</div><div class="line">	.css&#123;&#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>audio元素和video元素在ios和andriod中无法自动播放<br>应对方案：触屏即播</p>
<figure class="highlight javascript"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">$(<span class="string">'html'</span>).one(<span class="string">'touchstart'</span>,<span class="function"><span class="keyword">function</span>(<span class="params"></span>)</span>&#123; audio.play()&#125;)</div></pre></td></tr></table></figure>
<p>可参考《<a href="http://www.cnblogs.com/PeunZhang/archive/2013/02/05/2893093.html" target="_blank" rel="external">无法自动播放的audio元素</a>》</p>
<p>摇一摇功能</p>
<p>HTML5 deviceMotion：封装了运动传感器数据的事件，可以获取手机运动状态下的运动加速度等数据。</p>
<p>体验demo：<a href="http://1.peunzhang.sinaapp.com/demo/deviceMotion/index.html" target="_blank" rel="external"></a><br><img src="http://upload-images.jianshu.io/upload_images/1064727-8f498bb8f55c4844.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240" alt=""></p>
<p>手机拍照和上传图片</p>
<figure class="highlight ada"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;input <span class="keyword">type</span>=<span class="string">"file"</span>&gt;的<span class="keyword">accept</span> 属性</div></pre></td></tr></table></figure>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!-- 选择照片 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">file</span> <span class="attr">accept</span>=<span class="string">"image/*"</span>&gt;</span></div><div class="line"><span class="comment">&lt;!-- 选择视频 --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">input</span> <span class="attr">type</span>=<span class="string">file</span> <span class="attr">accept</span>=<span class="string">"video/*"</span>&gt;</span></div></pre></td></tr></table></figure>
<h4 id="使用总结："><a href="#使用总结：" class="headerlink" title="使用总结："></a>使用总结：</h4><figure class="highlight actionscript"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">ios 有拍照、录像、选取本地图片功能</div><div class="line">部分android只有选取本地图片功能</div><div class="line">winphone不支持</div><div class="line">input控件默认外观丑陋</div><div class="line"></div><div class="line">微信浏览器用户调整字体大小后页面矬了，怎么阻止用户调整</div><div class="line">原因</div><div class="line">android侧是复写了layoutinflater 对textview做了统一处理</div><div class="line">ios侧是修改了body.style.webkitTextSizeAdjust值</div><div class="line"></div><div class="line">解决方案：</div><div class="line">android使用以下代码，该接口只在微信浏览器下有效(感谢jationhuang同学提供)</div><div class="line"></div><div class="line"></div><div class="line">/ * 页面加入这段代码可使Android机器页面不再受到用户字体缩放强制改变大小 * 但是会有一个<span class="number">1</span>秒左右的延迟，期间可以考虑通过loading展示 * 仅供参考 */(<span class="function"><span class="keyword">function</span><span class="params">()</span></span>&#123; <span class="keyword">if</span> (<span class="keyword">typeof</span>(WeixinJSBridge) == <span class="string">"undefined"</span>) &#123; document.addEventListener(<span class="string">"WeixinJSBridgeReady"</span>, <span class="function"><span class="keyword">function</span> <span class="params">(e)</span> </span>&#123; setTimeout(<span class="function"><span class="keyword">function</span><span class="params">()</span></span>&#123; WeixinJSBridge.invoke(<span class="string">'setFontSizeCallback'</span>,&#123;<span class="string">"fontSize"</span>:<span class="number">0</span>&#125;, <span class="function"><span class="keyword">function</span><span class="params">(res)</span> </span>&#123; alert(JSON.stringify(res)); &#125;); &#125;,<span class="number">0</span>); &#125;); &#125; <span class="keyword">else</span> &#123; setTimeout(<span class="function"><span class="keyword">function</span><span class="params">()</span></span>&#123; WeixinJSBridge.invoke(<span class="string">'setFontSizeCallback'</span>,&#123;<span class="string">"fontSize"</span>:<span class="number">0</span>&#125;, <span class="function"><span class="keyword">function</span><span class="params">(res)</span> </span>&#123; alert(JSON.stringify(res)); &#125;); &#125;,<span class="number">0</span>); &#125;&#125;)();</div></pre></td></tr></table></figure>
<h4 id="ios使用-webkit-text-size-adjust禁止调整字体大小"><a href="#ios使用-webkit-text-size-adjust禁止调整字体大小" class="headerlink" title="ios使用-webkit-text-size-adjust禁止调整字体大小"></a>ios使用-webkit-text-size-adjust禁止调整字体大小</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">body</span>&#123;<span class="attribute">-webkit-text-size-adjust</span>: <span class="number">100%</span><span class="meta">!important</span>;&#125;</div><div class="line"></div><div class="line">最好的解决方案：</div><div class="line">整个页面用<span class="selector-tag">rem</span>或者百分比布局</div></pre></td></tr></table></figure>
<h4 id="消除transition闪屏"><a href="#消除transition闪屏" class="headerlink" title="消除transition闪屏"></a>消除transition闪屏</h4><figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">网络都是这么写的，但我并没有测试出来</div><div class="line"><span class="selector-class">.css</span>&#123;<span class="comment">/*设置内嵌的元素在 3D 空间如何呈现：保留 3D*/</span><span class="attribute">-webkit-transform-style</span>: preserve-<span class="number">3</span>d;<span class="comment">/*（设置进行转换的元素的背面在面对用户时是否可见：隐藏）*/</span><span class="attribute">-webkit-backface-visibility</span>: hidden;&#125;</div><div class="line">开启硬件加速</div><div class="line">解决页面闪白</div><div class="line">保证动画流畅</div></pre></td></tr></table></figure>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line"><span class="selector-class">.css</span> &#123; <span class="attribute">-webkit-transform</span>: <span class="built_in">translate3d</span>(0, 0, 0); <span class="attribute">-moz-transform</span>: <span class="built_in">translate3d</span>(0, 0, 0); <span class="attribute">-ms-transform</span>: <span class="built_in">translate3d</span>(0, 0, 0); <span class="attribute">transform</span>: <span class="built_in">translate3d</span>(0, 0, 0);&#125;</div></pre></td></tr></table></figure>
<p>参考《<a href="http://www.cnblogs.com/PeunZhang/p/3510083.html" target="_blank" rel="external">用CSS开启硬件加速来提高网站性能</a>》<br>取消input在ios下，输入的时候英文首字母的默认大写</p>
<figure class="highlight routeros"><table><tr><td class="gutter"><pre><div class="line">1</div></pre></td><td class="code"><pre><div class="line">&lt;input <span class="attribute">autocapitalize</span>=<span class="string">"off"</span> <span class="attribute">autocorrect</span>=<span class="string">"off"</span> /&gt;</div></pre></td></tr></table></figure>
<p>android 上去掉语音输入按钮<br>input::-webkit-input-speech-button {display: none}</p>
<p>android 2.3 bug<br>@-webkit-keyframes 需要以0%开始100%结束，0%的百分号不能去掉<br>after和before伪类无法使用动画animation<br>border-radius不支持%单位<br>translate百分比的写法和scale在一起会导致失效，例如-webkit-transform: translate(-50%,-50%) scale(-0.5, 1)</p>
<p>android 4.x bug<br>三星 Galaxy S4中自带浏览器不支持border-radius缩写<br>同时设置border-radius和背景色的时候，背景色会溢出到圆角以外部分<br>部分手机(如三星)，a链接支持鼠标:visited事件，也就是说链接访问后文字变为紫色<br>android无法同时播放多音频audio</p>
<p>参考《<a href="https://github.com/yisibl/blog/issues/2" target="_blank" rel="external">border-radius 移动之伤</a>》<br>设计高性能CSS3动画的几个要素<br>尽可能地使用合成属性transform和opacity来设计CSS3动画，不使用position的left和top来定位<br>利用translate3D开启GPU加速</p>
<p>参考《<a href="http://www.html5rocks.com/en/tutorials/speed/high-performance-animations/" target="_blank" rel="external">High Performance Animations</a>》<br>fixed bug<br>ios下fixed元素容易定位出错，软键盘弹出时，影响fixed元素定位<br>android下fixed表现要比iOS更好，软键盘弹出时，不会影响fixed元素定位<br>ios4下不支持position:fixed</p>
<p>解决方案<br>可用isroll.js，暂无完美方案</p>
<p>参考<br><a href="https://github.com/maxzhang/maxzhang.github.com/issues/2" target="_blank" rel="external">《移动端web页面使用position:fixed问题总结》</a><br><a href="http://www.cnblogs.com/PeunZhang/archive/2013/06/14/3117589.html" target="_blank" rel="external">《使用iScroll.js解决ios4下不支持position:fixed的问题》</a></p>
<h4 id="如何阻止windows-Phone的默认触摸事件"><a href="#如何阻止windows-Phone的默认触摸事件" class="headerlink" title="如何阻止windows Phone的默认触摸事件"></a>如何阻止windows Phone的默认触摸事件</h4><p>winphone下默认触摸事件事件使用e.preventDefault是无效的<br>目前解决方法是使用样式来禁用<br>html{-ms-touch-action: none;}/<em> 禁止winphone默认触摸事件 </em>/</p>
<p>《<a href="http://stackoverflow.com/questions/13396297/windows-phone-8-touch-support" title="播放视频不全屏" target="_blank" rel="external">Windows phone 8 touch support</a></p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line"><span class="comment">&lt;!--1.目前只有ios7+、winphone8+支持自动播放2.支持Airplay的设备（如：音箱、Apple TV)播放x-webkit-airplay="true" 3.播放视频不全屏，ios7+、winphone8+支持，部分android4+支持（含华为、小米、魅族）webkit-playsinline="true" --&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">video</span> <span class="attr">x-webkit-airplay</span>=<span class="string">"true"</span> <span class="attr">webkit-playsinline</span>=<span class="string">"true"</span> <span class="attr">preload</span>=<span class="string">"auto"</span> <span class="attr">autoplay</span> <span class="attr">src</span>=<span class="string">"http://"</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">video</span>&gt;</span></div></pre></td></tr></table></figure>
<p><a href="http://1.peunzhang.sinaapp.com/demo/video/index.html" target="_blank" rel="external">体验demo：</a></p>
<h4 id="常用的移动端框架"><a href="#常用的移动端框架" class="headerlink" title="常用的移动端框架"></a>常用的移动端框架</h4><p>zepto.js<br>语法与jquery几乎一样，会jquery基本会zepto~<br>最新版本已经更新到1.16<br><a href="http://zeptojs.com/" target="_blank" rel="external">官网：</a><br><a href="http://www.css88.com/doc/zeptojs_api/" target="_blank" rel="external">中文(非官网)：</a></p>
<p>常使用的扩展模块：<br><a href="https://github.com/madrobby/zepto/blob/master/src/detect.js" target="_blank" rel="external">浏览器检测：</a><br><a href="https://github.com/madrobby/zepto/blob/master/src/touch.js" target="_blank" rel="external">tap事件：</a></p>
<p>iscroll.js<br>解决页面不支持弹性滚动，不支持fixed引起的问题~<br>实现下拉刷新，滑屏，缩放等功能~<br>最新版本已经更新到5.0<br><a href="http://cubiq.org/iscroll-5" target="_blank" rel="external">官网：</a></p>
<p>underscore.js<br>笔者没用过，不过听说好用，推荐给大家~<br>该库提供了一整套函数式编程的实用功能，但是没有扩展任何JavaScript内置对象。<br>最新版本已经更新到1.8.2<br><a href="http://underscorejs.org/" target="_blank" rel="external">官网：</a></p>
<p>滑屏框架</p>
<p>适合上下滑屏、左右滑屏等滑屏切换页面的效果<br><a href="https://github.com/peunzhang/slip.js" target="_blank" rel="external">slip.js</a><br><a href="https://github.com/peunzhang/iSlider" target="_blank" rel="external">iSlider.js</a><br><a href="https://github.com/peunzhang/fullpage" target="_blank" rel="external">fullpage.js</a><br><a href="http://www.swiper.com.cn/" target="_blank" rel="external">swiper.js</a></p>
<h4 id="flex布局"><a href="#flex布局" class="headerlink" title="flex布局"></a>flex布局</h4><p>flex布局目前可使用在移动中，并非所有的语法都全兼容，但以下写法笔者实践过，效果良好~</p>
<figure class="highlight css"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div></pre></td><td class="code"><pre><div class="line"><span class="selector-tag">flex</span>：定义布局为盒模型 </div><div class="line"><span class="selector-tag">flex-v</span>：盒模型垂直布局 </div><div class="line"><span class="selector-tag">flex-1</span>：子元素占据剩余的空间 </div><div class="line"><span class="selector-tag">flex-align-center</span>：子元素垂直居中 </div><div class="line"><span class="selector-tag">flex-pack-center</span>：子元素水平居中 </div><div class="line"><span class="selector-tag">flex-pack-justify</span>：子元素两端对齐 </div><div class="line">兼容性：<span class="selector-tag">ios</span> 4+、<span class="selector-tag">android</span> 2<span class="selector-class">.3</span>+、<span class="selector-tag">winphone8</span>+ </div><div class="line"></div><div class="line"><span class="selector-class">.flex</span>&#123;</div><div class="line">	<span class="attribute">display</span>:-webkit-box;</div><div class="line">	<span class="attribute">display</span>:-webkit-flex;</div><div class="line">	<span class="attribute">display</span>:-ms-flexbox;</div><div class="line">	<span class="attribute">display</span>:flex;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.flex-v</span>&#123;</div><div class="line">	<span class="attribute">-webkit-box-orient</span>:vertical;</div><div class="line">	<span class="attribute">-webkit-flex-direction</span>:column;</div><div class="line">	<span class="attribute">-ms-flex-direction</span>:column;</div><div class="line">	<span class="attribute">flex-direction</span>:column;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.flex-1</span>&#123;</div><div class="line">	<span class="attribute">-webkit-box-flex</span>:<span class="number">1</span>;</div><div class="line">	<span class="attribute">-webkit-flex</span>:<span class="number">1</span>;</div><div class="line">	<span class="attribute">-ms-flex</span>:<span class="number">1</span>;</div><div class="line">	<span class="attribute">flex</span>:<span class="number">1</span>;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.flex-align-center</span>&#123;</div><div class="line">	<span class="attribute">-webkit-box-align</span>:center;</div><div class="line">	<span class="attribute">-webkit-align-items</span>:center;</div><div class="line">	<span class="attribute">-ms-flex-align</span>:center;</div><div class="line">	<span class="attribute">align-items</span>:center;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.flex-pack-center</span>&#123;</div><div class="line">	<span class="attribute">-webkit-box-pack</span>:center;</div><div class="line">	<span class="attribute">-webkit-justify-content</span>:center;</div><div class="line">	<span class="attribute">-ms-flex-pack</span>:center;</div><div class="line">	<span class="attribute">justify-content</span>:center;</div><div class="line">&#125;</div><div class="line"><span class="selector-class">.flex-pack-justify</span>&#123;</div><div class="line">	<span class="attribute">-webkit-box-pack</span>:justify;</div><div class="line">	<span class="attribute">-webkit-justify-content</span>:space-between;</div><div class="line">	<span class="attribute">-ms-flex-pack</span>:justify;</div><div class="line">	<span class="attribute">justify-content</span>:space-between;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h4 id="示例：两端对齐"><a href="#示例：两端对齐" class="headerlink" title="示例：两端对齐"></a>示例：两端对齐</h4><figure class="highlight xml"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line"><span class="meta">&lt;!DOCTYPE html&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">html</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">charset</span>=<span class="string">"utf-8"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=no"</span> <span class="attr">name</span>=<span class="string">"viewport"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"yes"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-capable"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"black"</span> <span class="attr">name</span>=<span class="string">"apple-mobile-web-app-status-bar-style"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"telephone=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">meta</span> <span class="attr">content</span>=<span class="string">"email=no"</span> <span class="attr">name</span>=<span class="string">"format-detection"</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">style</span> <span class="attr">type</span>=<span class="string">"text/css"</span>&gt;</span><span class="css"></span></div><div class="line"><span class="comment">/* </span></div><div class="line">flex：定义布局为盒模型</div><div class="line">flex-v：盒模型垂直布局</div><div class="line">flex-1：子元素占据剩余的空间</div><div class="line">flex-align-center：子元素垂直居中</div><div class="line">flex-pack-center：子元素水平居中</div><div class="line">flex-pack-justify：子元素两端对齐 兼容性：ios 4+、android 2.3+、winphone8+  */</div><div class="line"></div><div class="line"><span class="selector-class">.flex</span>&#123;</div><div class="line">	<span class="attribute">display</span>:-webkit-box;<span class="attribute">display</span>:-webkit-flex;<span class="attribute">display</span>:-ms-flexbox;<span class="attribute">display</span>:flex;&#125;<span class="selector-class">.flex-v</span>&#123;<span class="attribute">-webkit-box-orient</span>:vertical;<span class="attribute">-webkit-flex-direction</span>:column;<span class="attribute">-ms-flex-direction</span>:column;<span class="attribute">flex-direction</span>:column;&#125;<span class="selector-class">.flex-1</span>&#123;<span class="attribute">-webkit-box-flex</span>:<span class="number">1</span>;<span class="attribute">-webkit-flex</span>:<span class="number">1</span>;<span class="attribute">-ms-flex</span>:<span class="number">1</span>;<span class="attribute">flex</span>:<span class="number">1</span>;&#125;<span class="selector-class">.flex-align-center</span>&#123;<span class="attribute">-webkit-box-align</span>:center;<span class="attribute">-webkit-align-items</span>:center;<span class="attribute">-ms-flex-align</span>:center;<span class="attribute">align-items</span>:center;&#125;<span class="selector-class">.flex-pack-center</span>&#123;<span class="attribute">-webkit-box-pack</span>:center;<span class="attribute">-webkit-justify-content</span>:center;<span class="attribute">-ms-flex-pack</span>:center;<span class="attribute">justify-content</span>:center;&#125;<span class="selector-class">.flex-pack-justify</span>&#123;<span class="attribute">-webkit-box-pack</span>:justify;<span class="attribute">-webkit-justify-content</span>:space-between;<span class="attribute">-ms-flex-pack</span>:justify;<span class="attribute">justify-content</span>:space-between;&#125;<span class="tag">&lt;/<span class="name">style</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">head</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;<span class="name">div</span> <span class="attr">class</span>=<span class="string">"flex flex-pack-justify"</span>&gt;</span> <span class="tag">&lt;<span class="name">div</span>&gt;</span>模块一<span class="tag">&lt;/<span class="name">div</span>&gt;</span> <span class="tag">&lt;<span class="name">div</span>&gt;</span>模块二<span class="tag">&lt;/<span class="name">div</span>&gt;</span> <span class="tag">&lt;<span class="name">div</span>&gt;</span>模块三<span class="tag">&lt;/<span class="name">div</span>&gt;</span> <span class="tag">&lt;<span class="name">div</span>&gt;</span>模块四<span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">div</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">body</span>&gt;</span></div><div class="line"><span class="tag">&lt;/<span class="name">html</span>&gt;</span></div></pre></td></tr></table></figure>
<p>使用注意：<br>flex下的子元素必须为块级元素，非块级元素在android2.3机器下flex失效<br>flex下的子元素宽度和高度不能超过父元素，否则会导致子元素定位错误，例如水平垂直居中</p>
<p>参考：<br><a href="http://the-echoplex.net/flexyboxes/" target="_blank" rel="external">flexyboxes</a><br><a href="http://www.w3cplus.com/css3/old-flexbox-and-new-flexbox.html" target="_blank" rel="external">“老”的Flexbox和“新”的Flexbox</a><br><a href="http://www.w3cplus.com/css3/advanced-cross-browser-flexbox.html" target="_blank" rel="external">跨浏览器的Flexbox</a><br>FastClick<br>消除在移动浏览器上触发click事件与一个物理Tap(敲击)之间的300延迟<br>参考《<a href="https://github.com/ftlabs/fastclick" target="_blank" rel="external">FastClick</a>》<br>Sea.js<br>提供简单、极致的模块化开发体验<br>简单友好的模块定义规范：Sea.js 遵循 <a href="https://github.com/cmdjs/specification/blob/master/draft/module.md" target="_blank" rel="external">CMD</a> 规范，可以像 <a href="http://nodejs.org/" target="_blank" rel="external">Node.js</a> 一般书写模块代码。<br>自然直观的代码组织方式：依赖的自动加载、配置的简洁清晰，可以让我们更多地享受编码的乐趣。</p>
<p>地址：<a href="http://seajs.org/docs/" target="_blank" rel="external">http://seajs.org/docs/</a></p>
<p>目录（更新于20160128）<br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta" target="_blank" rel="external">meta基础知识</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_1" target="_blank" rel="external">H5页面窗口自动调整到设备宽度，并禁止用户缩放页面</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_2" target="_blank" rel="external">忽略将页面中的数字识别为电话号码</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_3" target="_blank" rel="external">忽略Android平台中对邮箱地址的识别</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_4" target="_blank" rel="external">当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_5" target="_blank" rel="external">将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#meta_6" target="_blank" rel="external">viewport模板</a></p>
<p><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question" target="_blank" rel="external">常见问题</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_1" target="_blank" rel="external">移动端如何定义字体font-family</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_2" target="_blank" rel="external">移动端字体单位font-size选择px还是rem</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_3" target="_blank" rel="external">移动端touch事件(区分webkit 和 winphone)</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_4" target="_blank" rel="external">移动端click屏幕产生200-300 ms的延迟响应</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_5" target="_blank" rel="external">触摸事件的响应顺序</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_6" target="_blank" rel="external">什么是Retina 显示屏，带来了什么问题</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_7" target="_blank" rel="external">ios系统中元素被触摸时产生的半透明灰色遮罩怎么去掉</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_8" target="_blank" rel="external">部分android系统中元素被点击时产生的边框怎么去掉</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_9" target="_blank" rel="external">winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_10" target="_blank" rel="external">webkit表单元素的默认外观怎么重置</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_11" target="_blank" rel="external">webkit表单输入框placeholder的颜色值能改变么</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_12" target="_blank" rel="external">webkit表单输入框placeholder的文字能换行么</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_13" target="_blank" rel="external">IE10（winphone8）表单元素默认外观如何重置</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_14" target="_blank" rel="external">禁止ios 长按时不触发系统的菜单，禁止ios&amp;android长按时下载图片</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_15" target="_blank" rel="external">禁止ios和android用户选中文字</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_16" target="_blank" rel="external">打电话发短信写邮件怎么实现</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_17" target="_blank" rel="external">模拟按钮hover效果</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_18" target="_blank" rel="external">屏幕旋转的事件和样式</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_19" target="_blank" rel="external">audio元素和video元素在ios和andriod中无法自动播放</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_20" target="_blank" rel="external">摇一摇功能</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_21" target="_blank" rel="external">手机拍照和上传图片</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_22" target="_blank" rel="external">微信浏览器用户调整字体大小后页面矬了，怎么阻止用户调整</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_23" target="_blank" rel="external">消除transition闪屏</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_24" target="_blank" rel="external">开启硬件加速</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_25" target="_blank" rel="external">取消input在ios下，输入的时候英文首字母的默认大写</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_26" target="_blank" rel="external">android上去掉语音输入按钮</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_27" target="_blank" rel="external">android 2.3 bug</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_28" target="_blank" rel="external">android 4.x bug</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_29" target="_blank" rel="external">设计高性能CSS3动画的几个要素</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_30" target="_blank" rel="external">fixed bug</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_31" target="_blank" rel="external">如何阻止windows Phone的默认触摸事件</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#question_32" target="_blank" rel="external">播放视频不全屏</a></p>
<p><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api" target="_blank" rel="external">常用的移动端框架</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_zepto" target="_blank" rel="external">zepto.js</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_iscroll" target="_blank" rel="external">iscroll.js</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_underscore" target="_blank" rel="external">underscore.js</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_slide" target="_blank" rel="external">滑屏框架</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_flex" target="_blank" rel="external">flex布局</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#api_FastClick" target="_blank" rel="external">FastClick</a><br><a href="http://www.cnblogs.com/PeunZhang/p/3407453.html#seajs" target="_blank" rel="external">Sea.js</a></p>
<p>移动布局：</p>
<p><a href="https://developer.mozilla.org/zh-CN/docs/Web/Guide/Mobile" target="_blank" rel="external">MDN:手机网页开发</a><br><a href="https://developer.mozilla.org/zh-CN/docs/Mobile/Viewport_meta_tag" target="_blank" rel="external">MDN:在移动浏览器中使用viewport元标签控制布局</a><br><a href="https://www.zhihu.com/question/20269059" target="_blank" rel="external">移动前端开发和 Web 前端开发的区别是什么</a><br><a href="http://alloyteam.github.io/Spirit/modules/Standard/" target="_blank" rel="external">Alloyteam移动开发规范概述</a><br><a href="http://sentsin.com/web/54.html" target="_blank" rel="external">手机/移动前端开发需要注意的20个要点</a><br><a href="http://www.w3cplus.com/responsive" target="_blank" rel="external">w3cplus响应式技术资源</a><br><a href="http://www.infoq.com/cn/articles/development-of-the-mobile-web-deep-concept" target="_blank" rel="external">浅谈移动Web开发</a><br><a href="https://github.com/AlloyTeam/Mars" target="_blank" rel="external">Alloyteam Mars</a><br><a href="http://junmer.github.io/mobile-dev-get-started/" target="_blank" rel="external">移动WEB开发入门</a><br><a href="https://github.com/jtyjty99999/mobileTech" target="_blank" rel="external">移动开发资源集合</a><br><a href="http://quirksmode.org/mobilewebhandbook/" target="_blank" rel="external">The Mobile Web Handbook</a><br><a href="http://www.w3ctech.com/topic/979" target="_blank" rel="external">MobileWeb 适配总结</a><br><a href="http://www.css88.com/archives/5480" target="_blank" rel="external">移动前端不得不了解的html5 head 头标签</a></p>

      
      
    </div>
    
  </div>
  
    
    <div class="copyright">
        <p><span>本文标题:</span><a href="/2016/01/28/Induce/Mobile/Mobile-knowledge/">移动前端知识总结</a></p>
        <p><span>文章作者:</span><a href="/" title="访问 安与生 的个人博客">安与生</a></p>
        <p><span>发布时间:</span>2016年01月28日 - 14时11分</p>
        <p><span>最后更新:</span>2017年07月28日 - 18时54分</p>
        <p>
            <span>原始链接:</span><a class="post-url" href="/2016/01/28/Induce/Mobile/Mobile-knowledge/" title="移动前端知识总结">http://Jimmey-Jiang.github.io/2016/01/28/Induce/Mobile/Mobile-knowledge/</a>
            <span class="copy-path" data-clipboard-text="原文: http://Jimmey-Jiang.github.io/2016/01/28/Induce/Mobile/Mobile-knowledge/　　作者: 安与生" title="点击复制文章链接"><i class="fa fa-clipboard"></i></span>
            <script src="/js/clipboard.min.js"></script>
            <script> var clipboard = new Clipboard('.copy-path'); </script>
        </p>
        <p>
            <span>许可协议:</span><i class="fa fa-creative-commons"></i> <a rel="license" href="http://creativecommons.org/licenses/by-nc-sa/3.0/cn/" title="中国大陆 (CC BY-NC-SA 3.0 CN)" target = "_blank">"署名-非商用-相同方式共享 3.0"</a> 转载请保留原文链接及作者。
        </p>
    </div>



<nav id="article-nav">
  
    <a href="/2016/02/20/Induce/CSS/animation/" id="article-nav-newer" class="article-nav-link-wrap">
      <strong class="article-nav-caption"><</strong>
      <div class="article-nav-title">
        
          CSS3动画探秘
        
      </div>
    </a>
  
  
    <a href="/2016/01/27/Induce/Ajax/Ajax/" id="article-nav-older" class="article-nav-link-wrap">
      <div class="article-nav-title">Ajax学习计划</div>
      <strong class="article-nav-caption">></strong>
    </a>
  
</nav>

  
</article>

    <div id="toc" class="toc-article">
    <strong class="toc-title">文章目录</strong>
    <ol class="toc"><li class="toc-item toc-level-3"><a class="toc-link" href="#常见问题"><span class="toc-number">1.</span> <span class="toc-text">常见问题</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#meta基础知识"><span class="toc-number">2.</span> <span class="toc-text">meta基础知识</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#H5页面窗口自动调整到设备宽度，并禁止用户缩放页面"><span class="toc-number">2.1.</span> <span class="toc-text">H5页面窗口自动调整到设备宽度，并禁止用户缩放页面</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#忽略将页面中的数字识别为电话号码"><span class="toc-number">2.2.</span> <span class="toc-text">忽略将页面中的数字识别为电话号码</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#忽略Android平台中对邮箱地址的识别"><span class="toc-number">2.3.</span> <span class="toc-text">忽略Android平台中对邮箱地址的识别</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari"><span class="toc-number">2.4.</span> <span class="toc-text">当网站添加到主屏幕快速启动方式，可隐藏地址栏，仅针对ios的safari</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式"><span class="toc-number">2.5.</span> <span class="toc-text">将网站添加到主屏幕快速启动方式，仅针对ios的safari顶端状态条的样式</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#viewport模板"><span class="toc-number">3.</span> <span class="toc-text">viewport模板</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#viewport模板——通用"><span class="toc-number">3.1.</span> <span class="toc-text">viewport模板——通用</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#viewport模板-target-densitydpi-device-dpi，android-2-3-5以下版本不支持"><span class="toc-number">3.2.</span> <span class="toc-text">viewport模板 - target-densitydpi=device-dpi，android 2.3.5以下版本不支持</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#rem配置参考："><span class="toc-number">4.</span> <span class="toc-text">rem配置参考：</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉"><span class="toc-number">4.1.</span> <span class="toc-text">winphone系统a、input标签被点击时产生的半透明灰色背景怎么去掉</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#webkit表单元素的默认外观怎么重置"><span class="toc-number">4.2.</span> <span class="toc-text">webkit表单元素的默认外观怎么重置</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#webkit表单输入框placeholder的颜色值能改变么"><span class="toc-number">4.3.</span> <span class="toc-text">webkit表单输入框placeholder的颜色值能改变么</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#webkit表单输入框placeholder的文字能换行么"><span class="toc-number">4.4.</span> <span class="toc-text">webkit表单输入框placeholder的文字能换行么</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#禁用-radio-和-checkbox-默认样式"><span class="toc-number">4.5.</span> <span class="toc-text">禁用 radio 和 checkbox 默认样式</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#禁用PC端表单输入框默认清除按钮"><span class="toc-number">4.6.</span> <span class="toc-text">禁用PC端表单输入框默认清除按钮</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#禁止ios-长按时不触发系统的菜单，禁止ios-amp-android长按时下载图片"><span class="toc-number">4.7.</span> <span class="toc-text">禁止ios 长按时不触发系统的菜单，禁止ios&android长按时下载图片</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#禁止ios和android用户选中文字"><span class="toc-number">4.8.</span> <span class="toc-text">禁止ios和android用户选中文字</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#打电话发短信写邮件怎么实现"><span class="toc-number">4.9.</span> <span class="toc-text">打电话发短信写邮件怎么实现</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#模拟按钮hover效果"><span class="toc-number">4.10.</span> <span class="toc-text">模拟按钮hover效果</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#使用总结："><span class="toc-number">4.11.</span> <span class="toc-text">使用总结：</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#ios使用-webkit-text-size-adjust禁止调整字体大小"><span class="toc-number">4.12.</span> <span class="toc-text">ios使用-webkit-text-size-adjust禁止调整字体大小</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#消除transition闪屏"><span class="toc-number">4.13.</span> <span class="toc-text">消除transition闪屏</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#如何阻止windows-Phone的默认触摸事件"><span class="toc-number">4.14.</span> <span class="toc-text">如何阻止windows Phone的默认触摸事件</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#常用的移动端框架"><span class="toc-number">4.15.</span> <span class="toc-text">常用的移动端框架</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#flex布局"><span class="toc-number">4.16.</span> <span class="toc-text">flex布局</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#示例：两端对齐"><span class="toc-number">4.17.</span> <span class="toc-text">示例：两端对齐</span></a></li></ol></li></ol>
</div>
<input type="button" id="tocButton" value="隐藏目录"  title="点击按钮隐藏或者显示文章目录">

<script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script>
    var valueHide = "隐藏目录";
    var valueShow = "显示目录";

    if ($(".left-col").is(":hidden")) {
        $("#tocButton").attr("value", valueShow);
    }
    $("#tocButton").click(function() {
        if ($("#toc").is(":hidden")) {
            $("#tocButton").attr("value", valueHide);
            $("#toc").slideDown(320);
        }
        else {
            $("#tocButton").attr("value", valueShow);
            $("#toc").slideUp(350);
        }
    })
    if ($(".toc").length < 1) {
        $("#toc, #tocButton").hide();
    }
</script>





<div class="bdsharebuttonbox">
	<a href="#" class="fx fa-weibo bds_tsina" data-cmd="tsina" title="分享到新浪微博"></a>
	<a href="#" class="fx fa-weixin bds_weixin" data-cmd="weixin" title="分享到微信"></a>
	<a href="#" class="fx fa-qq bds_sqq" data-cmd="sqq" title="分享到QQ好友"></a>
	<a href="#" class="fx fa-facebook-official bds_fbook" data-cmd="fbook" title="分享到Facebook"></a>
	<a href="#" class="fx fa-twitter bds_twi" data-cmd="twi" title="分享到Twitter"></a>
	<a href="#" class="fx fa-linkedin bds_linkedin" data-cmd="linkedin" title="分享到linkedin"></a>
	<a href="#" class="fx fa-files-o bds_copy" data-cmd="copy" title="分享到复制网址"></a>
</div>
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"2","bdSize":"24"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>




    
        <div id="gitments"></div>
<script src="/js/gitment.browser.js"></script>
<script>
    var gitment = new Gitment({
      id: window.location.pathname,
      owner: 'Jimmey-Jiang',
      repo: 'Jimmey-Jiang.github.io',
      oauth: {
        client_id: '7f50019c6a02c37e7aca',
        client_secret: 'd583910e6ae1492b375796d2c82efcda2cc67aae',
      },
    })
    gitment.render('gitments')
</script>
    



    <div class="scroll" id="post-nav-button">
        
            <a href="/2016/02/20/Induce/CSS/animation/" title="上一篇: CSS3动画探秘">
                <i class="fa fa-angle-left"></i>
            </a>
        
        <a title="文章列表"><i class="fa fa-bars"></i><i class="fa fa-times"></i></a>
        
            <a href="/2016/01/27/Induce/Ajax/Ajax/" title="下一篇: Ajax学习计划">
                <i class="fa fa-angle-right"></i>
            </a>
        
    </div>
    <ul class="post-list"><li class="post-list-item"><a class="post-list-link" href="/2017/08/29/Tool/GitWorkflows/">Git Workflows</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/19/Tool/Git/">Git速查手册</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/18/FrontFrame/Vue/VueComponents/">Vue组件探秘</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/18/Induce/InduceSass/">深入Sass</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/18/FrontFrame/Vue/KeepAlive/">keep-alive最佳实践</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/18/Induce/CSS/CssLowFrequency/">CSS低频属性</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/08/02/Tool/Terminal/">Terminal配置</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/25/Induce/Weixin/JS-SDK/">WeChat SDK</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/07/12/Induce/Hack/Canvas/">浏览器常见Bug——Canvas</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/04/25/FrontFrame/Vue/Vuex/">Vuex</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/25/Induce/HTML/Video/">Mobile Video</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/25/FrontFrame/Vue/VueRouter/">Vue Router</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/03/21/Tool/Sublime/sublimeMac/">Sublime Mac 快捷键</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/02/14/FrontFrame/React/React/">React初探</a></li><li class="post-list-item"><a class="post-list-link" href="/2017/01/02/Induce/CSS/CSSElementAlign/">用CSS实现元素垂直居中方案</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/31/Skill/norm/normCSS/">CSS前端代码规范</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/31/Skill/norm/normjs/">前端代码规范Javascript</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/31/Skill/norm/normhtml/">HTML前端代码规范</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/31/Skill/norm/normdev/">前端开发代码规范</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/27/FrontFrame/ReactNative/Components/RNCText/">React Native Text</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/27/FrontFrame/ReactNative/Components/RNCTextInput/">React Native TextInput</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/27/FrontFrame/ReactNative/Components/RNCImage/">React Native Image</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/27/FrontFrame/ReactNative/Components/RNComponents/">React Native 组件</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/26/FrontFrame/ReactNative/RNTest/">React Native 实战封装组件</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/26/FrontFrame/ReactNative/RNBasics/">React Native 基础</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/25/FrontFrame/ReactNative/RNSetOX/">React Native IOS环境搭建</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/25/FrontFrame/ReactNative/RNTools/">React Native开发工具</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/25/FrontFrame/ReactNative/RNSetAndroid/">React Native Android环境搭建（Window）</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/12/25/FrontFrame/ReactNative/RN/">React Native初探</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/05/08/Induce/Mobile/MobileGuide/">移动Web解决方案</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/04/02/Induce/JavaScript/JSInputSearch/">Input输入框的案例</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/04/02/Plug/Gulp/InduceGulp/">Gulp前端构建工具</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/04/02/Plug/Sublime/SublimeOmniMarkupPreviewer/">OmniMarkupPreviewer</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/04/02/Induce/HTML/HtmlRem/">移动H5自适应布局</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/03/02/Demo/TextShow/">BOOS信息展示与收缩</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/02/28/Demo/MobileRotate/">移动端横屏提示动画</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/02/27/Induce/Skill/OOCSS/">面向对象的CSS样式</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/02/27/Induce/Mobile/MobliePC/">关于移动端界面在PC端显示的实现</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/02/20/Induce/Node/NodeJsWeb/">Node.js实战 建立简单的Web服务器</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/02/20/Induce/CSS/animation/">CSS3动画探秘</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/28/Induce/Mobile/Mobile-knowledge/">移动前端知识总结</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/27/Induce/Ajax/Ajax/">Ajax学习计划</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/20/Plug/ChromePlug/">前端Chrome插件</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/19/Induce/JavaScript/JSTip/">原生JS TitleTip</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/19/Induce/Ajax/AjaxStatus/">Ajax Status请求状态</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/16/Interview/FrontMap/">【转】2015-2016前端知识体系</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/15/Induce/JavaScript/NativeJS/">原生JavaScript探索</a></li><li class="post-list-item"><a class="post-list-link" href="/2016/01/13/Induce/HTML/HTMLbase/">HTML结构零散</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/27/Hexo/GitHubHexo/">使用GitHub搭建Hexo博客</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/27/Hexo/HexoBug/">Hexo bug</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/27/Hexo/HexoPlug/">Hexo插件安装</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/27/Hexo/Hexo/">Hexo的使用介绍</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/27/Hexo/HexoTheme/">Hexo 主题：SPFK</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/26/Skill/win7Set/">电脑优化相关</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/25/Induce/CSS/CssTips/">CSS小技巧收藏</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/25/Interview/WebFront/">web前端职业规划</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/25/Induce/HTML/media/">响应式布局</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/25/Induce/CSS/CSS/">CSS学习计划</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/24/Tool/Sublime/Sublimemarkdown/">Markdown使用指南</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/21/Tool/Sublime/Sublimebest/">Sublime Text历练</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/21/Induce/JavaScript/JQueryCDN/">CDN公共库</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/21/Plug/Sublime/SublimePackage/">Sublime插件</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/21/Demohttps://tuchong.com/1496450//">前端资源导航</a></li><li class="post-list-item"><a class="post-list-link" href="/2015/12/11/Skill/BusyFront/">Busy前端工作室</a></li></ul>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
    <script>
        $(".post-list").addClass("toc-article");
        $(".post-list-item a").attr("target","_blank");
        $("#post-nav-button > a:nth-child(2)").click(function() {
            $(".fa-bars, .fa-times").toggle();
            $(".post-list").toggle(300);
            if ($(".toc").length > 0) {
                $("#toc, #tocButton").toggle(200, function() {
                    if ($(".switch-area").is(":visible")) {
                        $("#tocButton").attr("value", valueHide);
                        }
                    })
            }
            else {
            }
        })
    </script>



    <script>
        
    </script>
</div>
      <footer id="footer">
    <div class="outer">
        <div id="footer-info">
            <div class="footer-left">
                &copy; 2017 安与生
            </div>
            <div class="footer-right">
                <a href="http://hexo.io/" target="_blank">Hexo</a>  Theme <a href="https://github.com/Jimmey-Jiang/hexo-theme-spfk" target="_blank">spfk</a> by Jimmey-Jiang
            </div>
        </div>
        
            <div class="visit">
                
                    <span id="busuanzi_container_site_pv" style='display:none'>
                        <span id="site-visit" >海贼到访数: 
                            <span id="busuanzi_value_site_uv"></span>
                        </span>
                    </span>
                
                
                    <span>, </span>
                
                
                    <span id="busuanzi_container_page_pv" style='display:none'>
                        <span id="page-visit">本页阅读量: 
                            <span id="busuanzi_value_page_pv"></span>
                        </span>
                    </span>
                
            </div>
        
    </div>
</footer>

    </div>
    <script src="https://7.url.cn/edu/jslib/comb/require-2.1.6,jquery-1.9.1.min.js"></script>
<script src="/js/main.js"></script>

    <script>
        $(document).ready(function() {
            var backgroundnum = 24;
            var backgroundimg = "url(/background/bg-x.jpg)".replace(/x/gi, Math.ceil(Math.random() * backgroundnum));
            $("#mobile-nav").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
            $(".left-col").css({"background-image": backgroundimg,"background-size": "cover","background-position": "center"});
        })
    </script>




	<script>
	var _hmt = _hmt || [];
	(function() {
	  var hm = document.createElement("script");
	  hm.src = "//hm.baidu.com/hm.js?819b1c6493df653afb8c7846bc4b8db6";
	  var s = document.getElementsByTagName("script")[0]; 
	  s.parentNode.insertBefore(hm, s);
	})();
	</script>


<div class="scroll" id="scroll">
    <a href="#"><i class="fa fa-arrow-up"></i></a>
    <a href="#comments"><i class="fa fa-comments-o"></i></a>
    <a href="#footer"><i class="fa fa-arrow-down"></i></a>
</div>
<script>
    $(document).ready(function() {
        if ($("#comments").length < 1) {
            $("#scroll > a:nth-child(2)").hide();
        };
    })
</script>

<script async src="https://dn-lbstatics.qbox.me/busuanzi/2.3/busuanzi.pure.mini.js">
</script>

  <script language="javascript">
    $(function() {
        $("a[title]").each(function() {
            var a = $(this);
            var title = a.attr('title');
            if (title == undefined || title == "") return;
            a.data('title', title).removeAttr('title').hover(

            function() {
                var offset = a.offset();
                $("<div id=\"anchortitlecontainer\"></div>").appendTo($("body")).html(title).css({
                    top: offset.top - a.outerHeight() - 15,
                    left: offset.left + a.outerWidth()/2 + 1
                }).fadeIn(function() {
                    var pop = $(this);
                    setTimeout(function() {
                        pop.remove();
                    }, pop.text().length * 800);
                });
            }, function() {
                $("#anchortitlecontainer").remove();
            });
        });
    });
</script>


    <script type="text/javascript">
      window.onload = function(){
        document.getElementById("search").onclick = function(){
            console.log("search")
            search();
        }
      }
      function search(){
        (function(w,d,t,u,n,s,e){w['SwiftypeObject']=n;w[n]=w[n]||function(){
        (w[n].q=w[n].q||[]).push(arguments);};s=d.createElement(t);
        e=d.getElementsByTagName(t)[0];s.async=1;s.src=u;e.parentNode.insertBefore(s,e);
        })(window,document,'script','//s.swiftypecdn.com/install/v2/st.js','_st');

        _st('install','A1Pz-LKMXbrzcFg2FWi6','2.0.0');
      }
    </script>

  </div>
</body>
</html>